<?php
defined('_JEXEC') or die('Restricted access');
$tmpl = "templates/tpl_automobil/";
$db = JFactory::getDBO();
$sess = JFactory::getSession();
?>
<script type="text/javascript" src="<?php echo $tmpl;?>js/tooltips.js"></script>
<script type="text/javascript" src="<?php echo $tmpl;?>js/jquery.filestyle.js"></script>
<script type="text/javascript">
	jQuery(function() { 
		jQuery("input.file_1").filestyle({ 
		 image:"images/bt_browse.jpg",
		 imageheight : 29,
		 imagewidth : 80,
		 width : 220
 		});
	});
</script>
<link rel="stylesheet" href="<?php echo $tmpl;?>css/jquery.ui.all.css"/>
<script src="<?php echo $tmpl;?>js/jquery.ui.core.js"></script>
<script src="<?php echo $tmpl;?>js/jquery.ui.widget.js"></script>
<script src="<?php echo $tmpl;?>js/jquery.ui.datepicker.js"></script>
<script type="text/javascript" src="<?php echo $tmpl;?>js/jquery.ui.datepicker-da.js"></script>
<link rel="stylesheet" href="<?php echo $tmpl;?>css/datepicker.css"/>
<script>
$(document).ready(function(){
	checkMachinalDefect = function(){
		if($('#machinal_defect_nej').is(':checked')){
			$('#machinal_defect').val('');
			$('#machinal_defect').attr('disabled','disabled');
		}
		if($('#machinal_defect_ja').is(':checked')){
			$('#machinal_defect').removeAttr('disabled');
		}
	}
	checkMachinalDefect();
	
	checkElectricalDefect = function(){
		if($('#electrical_defect_nej').is(':checked')){
			$('#electrical_defect').val('');
			$('#electrical_defect').attr('disabled','disabled');
		}
		if($('#electrical_defect_ja').is(':checked')){
			$('#electrical_defect').removeAttr('disabled');
		}
	}
	checkElectricalDefect();
	
	checkServiceBook = function(){
		if($('#service_book_nej').is(':checked')){
			$('#service_book').attr('disabled','disabled');
		}
		if($('#service_book_ja').is(':checked')){
			$('#service_book').removeAttr('disabled');
		}
	}
	checkServiceBook();
	
	checkBelt = function(){
		if($('#belt_nej').is(':checked')){
			$('#belt').val('');
			$('#belt').attr('disabled','disabled');
		}
		if($('#belt_ja').is(':checked')){
			$('#belt').removeAttr('disabled');
		}
	}
	checkBelt();
	
	checkRepainted = function(){
		if($('#repainted_nej').is(':checked')){
			$('#repainted').val('');
			$('#repainted').attr('disabled','disabled');
		}
		if($('#repainted_ja').is(':checked')){
			$('#repainted').removeAttr('disabled');
		}
	}
	checkRepainted();
	
	checkParkingDamage = function(){
		if($('#parking_damage_nej').is(':checked')){
			$('#parking_damage').val('');
			$('#parking_damage').attr('disabled','disabled');
		}
		if($('#parking_damage_ja').is(':checked')){
			$('#parking_damage').removeAttr('disabled');
		}
	}
	checkParkingDamage();
	
	checkAccident = function(){
		if($('#accident_nej').is(':checked')){
			$('#accident').val('');
			$('#accident').attr('disabled','disabled');
		}
		if($('#accident_ja').is(':checked')){
			$('#accident').removeAttr('disabled');
		}
	}
	checkAccident();
		
	submitCar = function(){
		document.getElementById('sendInformationCar').click();
	}
	
	changeBrowse = function(stt) { 
		jQuery("input.file_"+stt).filestyle({ 
		 image:"images/bt_browse.jpg",
		 imageheight : 29,
		 imagewidth : 80,
		 width : 220
 		});
	}
	$('.moreUpload').click(function(e) {
        var num = $('#imageNum').val();
		stt = parseInt(num) + 6;
		html = '<label>Billede '+stt+':</label><fieldset><input type=\"file\" class=\"file_'+stt+'\ fileinput" name=\"imageadd'+num+'\"/></fieldset>';
		$('#moreField').append(html);
		changeBrowse(stt);
		$('#imageNum').val(parseInt(num)+1);
    });
});
</script>
<p><span class="float_left f28">Tilmelding af bil</span><span class="link-login"><a href="index.php?option=com_user&view=user&layout=profile&Itemid=13">
  <?php if($user->guest==0) {echo  "Min Profil";} ;?>
  </a><a href="index.php?option=com_user&view=login&task=logout&Itemid=13" class="m12l">
  <?php if($user->guest==0) {echo  "Log ud";};?>
  </a></span></p>
<div class="cb"></div>
<div class="tt m10b"></div>
<div class="p5t">
    <div class="status-step3"></div>
    <div class="w739 form_tilmelding1 float_left">
    	<form name="infoCar" id="infoCar" method="post" enctype="multipart/form-data">
            <input type="submit" name="sendInformationCar" id="sendInformationCar" style="display:none" />
            <input type="hidden" name="option" value="com_ecommerce" />
            <input type="hidden" name="task" value="saveStep4" />
        <div class="form_tilmelding3 float_left m20t w355">
        <h3 class="boder_b_d">Defekter</h3>
        <p class="m10b">Har bilen mekaniske defekter?</p>
        <input name="Radio1b" type="radio" id="machinal_defect_nej" onchange="checkMachinalDefect();" <?php if(!$sess->get('machinal_defect')) echo 'checked="checked"';?> /> <span class="pblack m5r">Nej</span>
        <input name="Radio1b" type="radio" id="machinal_defect_ja" onchange="checkMachinalDefect();" <?php if($sess->get('machinal_defect')) echo 'checked="checked"';?> /> <span class="pblack">Ja</span>
        <div class="cb m3b"></div>
        <textarea class="txa340" name="machinal_defect" id="machinal_defect" cols="" rows="" placeholder="Bemærkninger vedrørende mekaniske defekter"><?php echo $sess->get('machinal_defect');?></textarea>
        <div class="m10t"></div>
        <p class="m10b">Har bilen elektriske defekter?  </p>
        <input name="Radio1c" type="radio" id="electrical_defect_nej" onchange="checkElectricalDefect();" <?php if(!$sess->get('electrical_defect')) echo 'checked="checked"';?> /> <span class="pblack m5r">Nej</span>
        <input name="Radio1c" type="radio" id="electrical_defect_ja" onchange="checkElectricalDefect();" <?php if($sess->get('electrical_defect')) echo 'checked="checked"';?> /> <span class="pblack">Ja</span>
        <div class="cb m3b"></div>
        <textarea class="txa340" name="electrical_defect" id="electrical_defect" cols="" rows="" placeholder="Bemærkninger vedrørende elektriske defekter"><?php echo $sess->get('electrical_defect');?></textarea>
        <div class="m20t"></div>
        <h3 class="boder_b_d m10b">Vedligeholdelse</h3>
        <p class="m10b">Medfølger der servicebog til bilen?</p>
        <input name="Radio1d" type="radio" id="service_book_nej" onchange="checkServiceBook();" <?php if(!$sess->get('service_book')) echo 'checked="checked"';?>/> <span class="pblack m5r">Nej</span>
        <input name="Radio1d" type="radio" id="service_book_ja" onchange="checkServiceBook();" <?php if($sess->get('service_book')) echo 'checked="checked"';?>/> <span class="pblack m5r">Ja</span>
        
        <select name="service_book" id="service_book">
            <option <?php if($sess->get('service_book') == 'Alle service er overholdt') echo 'selected="selected"';?> value="Alle service er overholdt">Alle service er overholdt</option>
            <option <?php if($sess->get('service_book') == 'Delvis udfyldt servicebog') echo 'selected="selected"';?> value="Delvis udfyldt servicebog">Delvis udfyldt servicebog</option>
        </select>				    
        <div class="cl m3b"></div>

        <p class="m10b m10t">Er bilens tandrem tidligere blevet skiftet?</p>
        <div class="float_left m5t m5r">
            <input id="belt_nej" name="Radio1a" type="radio" onchange="checkBelt();" <?php if(!$sess->get('belt')) echo 'checked="checked"';?> /> <span class="pblack m5r">Nej</span>
            <input id="belt_ja" name="Radio1a" type="radio" onchange="checkBelt();" <?php if($sess->get('belt')) echo 'checked="checked"';?> /> <span class="pblack">Ja</span>
        </div>
        <div class="float_left">
            <input name="belt" type="text" class="txt_tilmelding_other" value="<?php echo $sess->get('belt');?>" id="belt"/>
            <span class="float_left" style="line-height:26px;">km </span>
        </div>

        <div class="cb"></div>
        <p class="m10b m10t">Er følgende foretaget indenfor de seneste kørte 10.000 km?</p>
        <p><input type="checkbox" name="front_brake" <?php if($sess->get('front_brake')) echo 'checked="checked"';?>/>
        <span class="pblack">Forreste bremser skiftet indenfor de seneste kørte 10.000 km</span></p>
        <p><input type="checkbox" name="rear_brake" <?php if($sess->get('rear_brake')) echo 'checked="checked"';?>/>
        <span class="pblack">Bagerste bremser skiftet indenfor de seneste kørte 10.000 km</span></p>
        <p><input type="checkbox" name="exhaust" <?php if($sess->get('exhaust')) echo 'checked="checked"';?>/>
        <span class="pblack">Udstødning udskiftet indenfor de seneste kørte 10.000 km</span></p>
        

        <div class="m20t"></div>
        <div class="cl"></div>
        
        </div>
        <div class="rightcol-auto m20t m38l w325 float_right">
        <h3 class="boder_b_d">Tidligere skader</h3>
        <p class="m10b">Er bilen tidligere omlakeret eller repareret i lakken?</p>
        <input name="Radio1e" type="radio" id="repainted_nej" onchange="checkRepainted();" <?php if(!$sess->get('repainted')) echo 'checked="checked"';?> /> <span class="pblack m5r">Nej</span>
        <input name="Radio1e" type="radio" id="repainted_ja" onchange="checkRepainted();" <?php if($sess->get('repainted')) echo 'checked="checked"';?>/> <span class="pblack">Ja</span>
        <div class="cb  m3b"></div>

        <textarea class="txa320" name="repainted" id="repainted" cols="" rows="" placeholder="Beskriv omfanget"><?php echo $sess->get('repainted');?></textarea>
        <div class="cb m3b"></div>
        <p class="m10b">Har bilen nogensinde været udsat for parkeringsskader eller hærværk?</p>
        <input name="Radio1f" type="radio" id="parking_damage_nej" onchange="checkParkingDamage();" <?php if(!$sess->get('parking_damage')) echo 'checked="checked"';?>/> <span class="pblack m5r">Nej</span>
        <input name="Radio1f" type="radio" id="parking_damage_ja" onchange="checkParkingDamage();" <?php if($sess->get('parking_damage')) echo 'checked="checked"';?>/> <span class="pblack">Ja</span>
        <div class="cb  m3b"></div>
        <textarea class="txa320" name="parking_damage" id="parking_damage" cols="" rows="" placeholder="Beskriv skadens omfang"><?php echo $sess->get('parking_damage');?></textarea>
        <div class="cb m3b"></div>
        <p class="m10b">Har bilen nogensinde været involveret i et færdselsuheld?</p>
        <input name="Radio1g" type="radio" id="accident_nej" onchange="checkAccident();" <?php if(!$sess->get('accident')) echo 'checked="checked"';?>/> <span class="pblack m5r">Nej</span>
        <input name="Radio1g" type="radio" id="accident_ja" onchange="checkAccident();" <?php if($sess->get('accident')) echo 'checked="checked"';?>/> <span class="pblack">Ja</span>
        <div class="cb  m3b"></div>
        <textarea class="txa320" name="accident" id="accident" cols="" rows="" placeholder="Beskriv skadens omfang"><?php echo $sess->get('accident');?></textarea>
        <div class="cb m3b"></div>
        <h3 class="boder_b_d">Billeder</h3>	
        <span>(Max. 2MB pr billede)</span>
        <div class="cb m10t"></div>
        <label>Billede 1:</label>
        <fieldset>
              <input type="file" class="file_1 fileinput" name="image"/>
            <div class="cb"></div>
          </fieldset>
        <label>Billede 2:</label>
        <fieldset>
              <input type="file" class="file_1 fileinput" name="image1"/>
            <div class="cb"></div>
          </fieldset>
        <label>Billede 3:</label>
        <fieldset>
              <input type="file" class="file_1 fileinput" name="image2"/>
            <div class="cb"></div>
          </fieldset>
         <label>Billede 4:</label>
        <fieldset>
              <input type="file" class="file_1 fileinput" name="image3"/>
            <div class="cb"></div>
         </fieldset>
         <label>Billede 5:</label>
        <fieldset>
              <input type="file" class="file_1 fileinput" name="image4"/>
            <div class="cb"></div>
         </fieldset>
         <div id="moreField"></div>
         <div class="cb m10t"></div>
          <img src="templates/tpl_automobil/images/btn_more_upload.jpg" class="moreUpload" style="cursor:pointer;" />
          <input type="hidden" id="imageNum" name="imageNum" value="0" />
          <div class="cb m10t"></div>
         Indsæt videolink eller youtube indlejring link <input name="video" type="text" class="txt_tilmelding_other" style="float:none; width:300px;" value="<?php echo $sess->get('video');?>" id="video"/>
        </div>
        <div class="cb"></div>
        <div class="m15t">
        	<?php if(JRequest::getVar('action') == 'edit'){?>
            <a href="javascript:void(0);" class="bt_save float_left btn" onclick="submitCar();"></a>
            <input type="hidden" name="action" value="edit" />
            <?php } else {?>
            <a class="bt_next1 float_left btn" href="javascript:void(0);" onclick="submitCar();"></a>
            <a class="btn_back float_left btn m12l" href="index.php?option=com_ecommerce&view=register&Itemid=7&layout=step3"></a>
            <?php }?>
        </div>
        </form>
      </div>

  </div>
